package org.testis.gui.mvc.model.testdesign;

import org.testis.gui.mvc.model.*;
import org.testis.gui.mvc.controller.testdesign.TestStepGroupController;

/**
 *
 * @author Cahit Emir Erel
 */
public class TestStepGroupModel extends AbstractModel {

    private Boolean m_critical = false;
    private Boolean m_runAlways = true;
    private Boolean m_testStepGroupVisibility = false;
    private Integer m_timeout = 0;
    private String m_description = "";
    private String m_name = "";
    private Integer m_numberOfRetryOnFail = 0;
    private Integer m_numberOfInvocationCount = 0;
    private Byte m_successPercentage = new Byte("100");

    public String getName() {
        return m_name;
    }

    public void setName(String name) {
        if (name == null) {
            name = "";
        }
        String oldName = m_name;
        m_name = name;
        firePropertyChange(TestStepGroupController.CHANGE_NAME,
                oldName,
                name);
    }

    public String getDescription() {
        return m_description;
    }

    public Byte getSuccessPercentage() {
        return m_successPercentage;
    }

    public void setSuccessPercentage(Byte successPercentage) {
        if (successPercentage == null) {
            return;
        }
        Byte oldSuccessPercentage = m_successPercentage;
        m_successPercentage = successPercentage;
        firePropertyChange(TestStepGroupController.CHANGE_SUCCESS_PERCENTAGE,
                oldSuccessPercentage,
                successPercentage);
    }

    public Integer getNumberOfInvocationCount() {
        return m_numberOfInvocationCount;
    }

    public void setNumberOfInvocationCount(Integer numberOfInvocationCount) {
        if (numberOfInvocationCount == null) {
            return;
        }
        Integer oldNumberOfInvocationCount = m_numberOfInvocationCount;
        m_numberOfInvocationCount = numberOfInvocationCount;
        firePropertyChange(
                TestStepGroupController.CHANGE_NUMBER_OF_INVOCATION_COUNT,
                oldNumberOfInvocationCount,
                numberOfInvocationCount);
    }

    public Integer getNumberOfRetryOnFail() {
        return m_numberOfRetryOnFail;
    }

    public void setNumberOfRetryOnFail(Integer numberOfRetryOnFail) {
        if (numberOfRetryOnFail == null) {
            return;
        }
        Integer oldNumberOfRetryOnFail = m_numberOfRetryOnFail;
        m_numberOfRetryOnFail = numberOfRetryOnFail;
        firePropertyChange(
                TestStepGroupController.CHANGE_NUMBER_OF_RETRY_ON_FAIL,
                oldNumberOfRetryOnFail,
                numberOfRetryOnFail);
    }

    public void setDescription(String description) {
        if (description == null) {
            description = "";
        }
        String oldDescription = m_description;
        m_description = description;
        firePropertyChange(TestStepGroupController.CHANGE_DESCRIPTION,
                oldDescription,
                description);
    }

    public Integer getTimeout() {
        return m_timeout;
    }

    public void setTimeout(Integer timeout) {
        if (timeout == null) {
            return;
        }
        Integer oldTimeout = m_timeout;
        m_timeout = timeout;
        firePropertyChange(TestStepGroupController.CHANGE_TIMEOUT,
                oldTimeout,
                timeout);
    }

    public void setTestStepGroupVisibility(Boolean testStepGroupVisibility) {
        if (testStepGroupVisibility == null) {
            return;
        }
        Boolean oldTestStepGroupVisibility = m_testStepGroupVisibility;
        m_testStepGroupVisibility = testStepGroupVisibility;
        firePropertyChange(TestStepGroupController.SHOW_ADD_TEST_STEP_GROUP,
                oldTestStepGroupVisibility,
                testStepGroupVisibility);
    }

    public Boolean getTestStepGroupVisibility() {
        return m_testStepGroupVisibility;
    }

    public Boolean getRunAlways() {
        return m_runAlways;
    }

    public void setRunAlways(Boolean runAlways) {
        if (runAlways == null) {
            return;
        }
        Boolean oldRunAlways = m_runAlways;
        m_runAlways = runAlways;
        firePropertyChange(TestStepGroupController.CHANGE_RUN_ALWAYS,
                oldRunAlways,
                runAlways);
    }

    public Boolean getCritical() {
        return m_critical;
    }

    public void setCritical(Boolean critical) {
        if (critical == null) {
            return;
        }
        Boolean oldCritical = m_critical;
        m_critical = critical;
        firePropertyChange(TestStepGroupController.CHANGE_CRITICAL,
                oldCritical,
                critical);
    }
}
